{include file='default/head' /}

<!-- Page content -->
<div class="page-content">
    <!-- Page title -->
    <div class="page-title">
        <div class="row justify-content-between align-items-center">
            <div class="col-md-6 mb-3 mb-md-0">
                <h5 class="h3 font-weight-400 mb-0 text-white">{$title}</h5>
            </div>
        </div>
    </div>
    <!-- Page title -->
    <!-- 主体 -->
    <div class="row">
        <div class="col-xl-12 col-md-12 col-lg-12">

            <div class="card">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-xl-12 col-md-12 col-lg-12 mb-0 mb-sm-0">
                            <span class="text-sm h5">{$msg}</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <input type="hidden" id="token" value="{$Request.token}">
    <div class="row" id="collection">
        <div class="col-xl-12 col-md-12 col-lg-12">
            <div class="card card-fluid">
                <div class="card-header">
                    <h6 class="mb-0">收款服务能力</h6>
                </div>
                <div class="card-body">

                    <div class="row align-items-center">
                        <div class="col-xl-12 col-md-12 col-lg-12 mb-0 mb-sm-0">
                            <a href="#" class="text-sm h5">{$user['expiration_time']}</a>
                        </div>
                    </div>
                    <br/>

                    <div class="form-group mb-2">
                        <div class="input-group">
                            <div class="input-group-prepend"><span class="input-group-text">服务费用</span></span>
                            </div>
                            <input type="text" class="form-control" value="{$core['collection_cost']}元/月" disabled>
                        </div>
                    </div>
                    <div class="form-group mb-2">
                        <div class="input-group">
                            <div class="input-group-prepend"><span class="input-group-text">续费时长</span></span>
                            </div>
                            <input type="text" class="form-control" name="month" id="month" placeholder="请填写续费时长....">
                            <div class="input-group-append">
                                <span class="input-group-text">月</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group mb-2">
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text">支付方式</span></span>
                            </div>
                            {foreach name="pay_list" item="v" key="key"}
                            {if condition="$v['switch']"}
                            <label style="line-height: 40px">&nbsp;&nbsp;&nbsp;<input type="radio" name="type" value="{$v['alias']}" {$v['active']? 'checked' : ''}>&nbsp;<img style="vertical-align:middle" src="__PUBLIC__/icon/{$v['icon']}" width="18"/>&nbsp;{$v['name']}</label>
                            {/if}
                            {/foreach}
                        </div>
                    </div>

                    <br/>

                    <button type="button" class="btn btn-sm btn-primary" id="collection_submit">
                        <span class="btn-inner--text">确认续费</span>
                    </button>

                </div>
            </div>
        </div>
    </div>
    <!-- 主体 -->
</div>

{include file='default/bottom' /}

<script>
    $("#collection_submit").click(function (){
        var Load = layer.load(2, {shade: [0.3, '#000']}); //开始加载
        $.ajax({
            type: "POST",
            url: "/user/renew/collection",
            data: {"month":$('#month').val(),"type":$('input[name="type"]:checked').val(),"__token__":$("#token").val()},
            dataType: "json",
            success: function (json) { //SUCCESS
                var data = $.parseJSON(json);
                if (data.code == 0) {
                    layer.close(Load); //关闭加载
                    var indexa = layer.msg(data.msg, {time: 1000, icon: 6}, function () {
                        layer.close(indexa);
                        window.location.href = data.url;
                    });
                } else {
                    layer.close(Load); //关闭加载
                    var indexa = layer.alert(data.msg, {title: data.title, icon: 5}, function () {
                        layer.close(indexa);
                        // window.location.reload();
                    })
                }
            },
            error: function () { //ERROR
                layer.close(Load); //关闭加载
                layer.msg('系统繁忙');
                return false;
            }
        });
    });
</script>